﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace Main
{
    public partial class FormSettings : Form
    {

        public static string DIC_PATH = string.Empty;
        public static int THREAD_NUM = 10;

        private string tempFileName = string.Empty;

        public FormSettings()
        {
            InitializeComponent();
            
        }

        private void btnBrow_Click(object sender, EventArgs e)
        {
            string filename = string.Empty;
            OpenFileDialog dlg = new OpenFileDialog();
            dlg.Filter = "All files (*.*)|*.*|txt files (*.txt)|*.txt";
            dlg.FilterIndex = 2;
            dlg.RestoreDirectory = true;
            if (dlg.ShowDialog() == DialogResult.OK)
            {
                filename = dlg.FileName;
            }
            dlg.Dispose();
            tempFileName = filename;
            //txtDicPath.Text = filename;
        }

        private void FormSettings_Load(object sender, EventArgs e)
        {
            tempFileName = DIC_PATH;
            //txtDicPath.Text = DIC_PATH;
            //txtThreadNum.Text = THREAD_NUM.ToString();

        }

        private void btnCancel_Click(object sender, EventArgs e)
        {
            this.Close();
        }

        private void btnSave_Click(object sender, EventArgs e)
        {
            
            try
            {
                DIC_PATH = tempFileName;
                
                /*if(Int32.Parse(txtThreadNum.Text) <= 0)
                {
                    MessageBox.Show("线程数量必须大于0");
                    return;
                }
                THREAD_NUM = Int32.Parse(txtThreadNum.Text);*/
                this.Close();
            }
            catch (Exception e1)
            {
                MessageBox.Show(e1.Message);
                return;
            }
            
        }
    }
}
